package com.itheima.springbootwebtlias.controller;


import com.itheima.springbootwebtlias.pojo.Result;
import com.itheima.springbootwebtlias.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private ReportService reportService;

    //员工职位数据统计（柱状图）
    @GetMapping("/empJobData")
    public Result jobCount() {
        //1.接收请求参数，无

        //2.调用业务层功能方法，查询统计员工职位数据
        Map jobOption = reportService.jobCount();
        //3.封装响应数据
        return Result.success(jobOption);
    }

    //员工性别数据统计（饼图）
    @GetMapping("/empGenderData")
    public Result genderCount() {
        //1.接收请求参数，无

        //2.调用业务层功能方法，查询统计员工性别数据
        List<Map> map = reportService.genderCount();
        //3.封装响应数据
        return Result.success(map);
    }

    //5.4班级人数统计(柱状图)
    @GetMapping("/studentCountData")
    public Result studentsCount() {
        //1.接收请求参数，无

        //2.调用业务层功能方法，查询班级人数统计
        Map studentsCount = reportService.studentsCount();
        //3.封装响应数据
        return Result.success(studentsCount);
    }

    //5.3 学员学历统计(饼图)
    @GetMapping("/studentDegreeData")
    public Result studentDegreeCount() {
        //1.接收请求参数，无

        //2.调用业务层功能方法，查询学员学历统计
       List<Map> map =  reportService.studentDegreeCount();
        //3.封装响应数据
        return Result.success(map);

    }
}
